package cn.com.demo.tp01.config;

import cn.com.demo.tp01.filter.Factory.MyFilter4XML;
import cn.com.demo.tp01.filter.Factory.myGatewayFilterGatewayFilterFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class GatewayConfiguration {
    @Autowired
    private MyFilter4XML myFilter4XML;


   @Bean
    RouteLocator routeLocator(@Autowired RouteLocatorBuilder routeLocatorBuilder){
        return routeLocatorBuilder.routes()
                .route("header",j->j.path("/guonei").uri("http://news.baidu.com/guonei").filter(myFilter4XML)).build();

   }
}
